//
//  JxSegmentedView+Extensions.swift
//  DaRings
//
//  Created by 尹琼 on 2022/10/31.
//

import UIKit
import JXSegmentedView
import MYModule

public extension JXSegmentedView {
    
    @discardableResult
    func commonConfig(backgroundColor: UIColor, inset: CGFloat = 28.0) ->JXSegmentedView {
        
        self.backgroundColor = backgroundColor
        self.contentEdgeInsetLeft = inset
        self.contentEdgeInsetRight = inset
        
        return self
    }
    
}

public extension JXSegmentedTitleDataSource {
    
    @discardableResult
    func commonConfig(titles: [String],
                      itemWidth: CGFloat = 80.0,
                      titleNormalFont: UIFont = Fonts.systemFont(ofSize: 14),
                      titleSelectedFont: UIFont = Fonts.systemFont(ofSize: 14),
                      titleSelectedColor: UIColor = UIColor.assist_FFFFFF,
                      titleNormalColor: UIColor = UIColor.assist_A9A9A9) -> JXSegmentedTitleDataSource {
        
        self.titles = titles
        self.itemWidth = itemWidth
        self.titleSelectedColor = titleSelectedColor
        self.titleNormalColor = titleNormalColor
        self.titleNormalFont = titleNormalFont
        self.titleSelectedFont = titleSelectedFont
        self.isItemTransitionEnabled = false
        
        return self
    }
    
}

public extension JXSegmentedIndicatorBackgroundView {
    
    @discardableResult
    func commonConfig(indicatorHeight: CGFloat = 39.0,
                         indicatorColor: UIColor = UIColor.assist_FFFFFF,
                         shadowColor: UIColor,
                         shadowRadius: CGFloat = 16.0,
                         shadowOffset: CGSize = CGSize(width: 0, height: 4),
                         shadowOpacity: Float = 0.1) -> JXSegmentedIndicatorBackgroundView {
        
        
        self.indicatorHeight = indicatorHeight
        
        self.indicatorColor = indicatorColor
        self.layer.shadowColor = shadowColor.cgColor
        self.layer.shadowRadius = shadowRadius
        self.layer.shadowOffset = shadowOffset
        self.layer.shadowOpacity = shadowOpacity
        
        return self
    }
    
}
